package model;

import java.io.Serializable;
import java.net.InetAddress;

import cs.remoteapp.Message;


/**
 * Abstract class used to transmit app messages from the NI to the controller
 * 
 * <p>
 * <ul>
 * <li>Project: 	ChatSystemG3</li>
 * <li>Called by: 	model.*</li>
 * </ul>
 * </p>
 * 
 * @author COMBES Nicolas - LECHANTRE Arnaud
 * @see Serializable
 */
public class Datagram implements Serializable {

	/**
	 * Usefull for serialization
	 */
	private static final long serialVersionUID = 1L;	
	/**
	 * Used for saving the address into the model in order to be able to send somme messages to the remote user
	 */
	private InetAddress remoteAddress;	
	/**
	 * Message sent by the user
	 */
	private Message message;								
	
	/**
	 * Construct
	 * @param localAddress
	 * @param inetAddress
	 */
	public Datagram(InetAddress inetAddress, Message receivedMess) {
		this.remoteAddress = inetAddress;
		this.message=receivedMess;
	}

	/**
	 * getRemoteAddress
	 * @return address of remote user who has sent the datagram 
	 */
	public InetAddress getRemoteAddress() {
		return remoteAddress;
	}

	/**
	 * Saves the remote user address
	 * @param remoteAddress : address of the remote user
	 */
	public void setRemoteAddress(InetAddress remoteAddress) {
		this.remoteAddress = remoteAddress;
	}

	/**
	 * getMessage
	 * @return the message contained in the datagram
	 */
	public Message getMessage() {
		return message;
	}

	/**
	 * Saves the message sent by the remote user in order to let the controller analyze it
	 * @param message message to set into Datagram object, usually received messages
	 */
	public void setMessage(Message message) {
		this.message = message;
	}
	
}
